<template>
    <el-dialog title='预先结案' :visible.sync="dialogVisible" @opened="dialogOpen">
        <el-form ref="form" :model="form" label-width="80px" size="small">
            <el-row :gutter="20">
                <el-col :span="12">
                    <el-form-item label="结案原因" prop="endReason ">
                        <el-input v-model="form.endReason" placeholder="待处理"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="办理人" prop="endPerson">
                        <el-input v-model="form.endPerson"  readonly placeholder="待处理"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row :gutter="20">
                <el-col :span="12">
                    <el-form-item label="结案日期" prop="endTime">
                        <el-date-picker
                                v-model="form.endTime"
                                type="date"
                                value-format="timestamp"
                                placeholder="选择日期"
                                style="width:100%"
                        ></el-date-picker>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-form-item class="from-bnts">
                <el-button type="primary" @click="submit">保存</el-button>
                <el-button @click="close">取消</el-button>
            </el-form-item>
        </el-form>
    </el-dialog>
</template>
<script>
    import deptApi from "@/api/system/dept";
    import utils from '@/assets/utils/zhzf-util';
    import caseclueApi from "@/api/system/caseclue";
    import dictCache from "@/assets/utils/cache-dict-util";
    import TreeSelect from "@/views/comps/zhzf/tree-select";
    export default {
        name: "beforeend",
        components: {TreeSelect},
        props: {
            value: Boolean
        },
        data() {
            return {
                loading: false,
                dialogVisible: false,
                form: {},
                detail:{}
            };
        },

        watch: {
            value(val) {
                this.dialogVisible = val;
            },
            dialogVisible(val) {
                this.$emit("input", val);
            }
        },
        methods: {
            async getdepData(param){
                this.detail = param;
                this.dialogVisible = true;
                this.form.endPerson =  this.$store.state.d2admin.user.info.username;
            },
            async dialogOpen() {
            },
            submit() {
                this.$refs["form"].validate(async valid => {
                    if (!valid) {
                        return false;
                    }
                    this.loading = true;
                    await this.beforefinsh();
                    this.loading = false;
                    this.dialogVisible = false;
                    this.$emit("submit");
                });
            },
            async beforefinsh(){
                this.form.endStatus = '预先结案';
                this.form.caseClueId = this.detail.caseClueId;
                let method =caseclueApi.mod;
                let res = await method({...this.form});
                if(res.ok){
                    utils.showTips(res.msg);
                }
            },
            close() {
                this.$refs["form"].resetFields();
                this.dialogVisible = false;
            }
        }
    };
</script>

